//package com.ljt.config;
//
//import com.ljt.common.utils.RedisUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.cloud.gateway.route.RouteDefinition;
//import org.springframework.cloud.gateway.route.RouteDefinitionRepository;
//import org.springframework.cloud.gateway.support.NotFoundException;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Component;
//import reactor.core.publisher.Flux;
//import reactor.core.publisher.Mono;
//
//import java.util.LinkedHashMap;
//import java.util.Map;
//
//@Component
//public class RedisRouteRepositoryComponent implements RouteDefinitionRepository {
//    private Logger log = LoggerFactory.getLogger(RedisRouteRepositoryComponent.class);
//
//    private final String ROUTE = "route";
//    @Autowired
//    private RedisUtil redisUtil;
//    @Autowired
//    private RedisTemplate<String, Object> redisTemplate;
//
//    @Override
//    public Mono<Void> save(Mono<RouteDefinition> route) {
//        return route.flatMap(r -> {
//            log.info("保存路由信息{}", r);
////            redisComponent.addHashKey(ROUTE, r.getId(), r);
//            return Mono.empty();
//        });
//
//    }
//
//    @Override
//    public Mono<Void> delete(Mono<String> routeId) {
//        return routeId.flatMap(id -> {
////            if (redisComponent.hashGet(ROUTE,id)) {
////                log.info("删除路由信息{}", id);
//////                redisComponent.delHashKey(ROUTE, id);
////                return Mono.empty();
////            }
//            return Mono.defer(() -> Mono.error(
//                    new NotFoundException("RouteDefinition not found: " + routeId)));
//        });
//    }
//
//    @Override
//    public Flux<RouteDefinition> getRouteDefinitions() {
//        Map<String,RouteDefinition> routes = new LinkedHashMap<>();
//        log.info("拉取路由信息");
//
//
//        return Flux.fromIterable(routes.values());
//
//    }
//}
